//
//  Person.m
//  作业5
//
//  Created by dllo on 16/7/8.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "Person.h"

@implementation Person
- (instancetype)initWithName:(NSString *)name
                         age:(NSInteger)age
                         sex:(NSString *)sex {
    if (self = [super init]) {
        _name = name;
        _age = age;
        _sex = sex;
    }
    return self;
}
- (NSString *)description {
    return [NSString stringWithFormat:@"%@ %@ %ld",_name,_sex,_age];
}
- (NSComparisonResult)compareAge:(Person *)anotherPerson {
    return [[NSNumber numberWithInteger:_age] compare:[NSNumber numberWithInteger:anotherPerson.age]];
}
- (NSComparisonResult)compareName:(Person *)anotherPerson {
    return [_name compare:anotherPerson.name];
}
- (NSComparisonResult)compareSex:(Person *)anotherPerson {
     return [_sex compare:anotherPerson.sex];
}
@end
